package com.px.baolaiapi.controller;


import com.px.common.api.CommonResult;
import com.px.baolaiapi.dto.SendOutMaterialListDto;
import com.px.baolaiapi.page.SendOutMaterialListPage;
import com.px.baolaiapi.service.ISendOutMaterialListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 委外发料单表 前端控制器
 * </p>
 *
 * @author 品讯科技
 * @since 2022-03-23
 */
@Api(tags = "委外发料单api")
@RestController
@RequestMapping("/send-out-material-list")
public class SendOutMaterialListController {

    @Autowired
    private ISendOutMaterialListService sendOutMaterialListService;

    @ApiOperation("添加委外发料单")
    @PostMapping("/addSendOutMaterialList")
    public CommonResult addSendOutMaterialList(@RequestBody @Validated SendOutMaterialListDto sendOutMaterialListDto){

        int status = sendOutMaterialListService.addSendOutMaterialList(sendOutMaterialListDto);
        if (status > 0) {
            return CommonResult.success(status);
        }
        return CommonResult.failed();
    }

    @ApiOperation("分页查询委外发料单列表")
    @PostMapping("/querySendOutMaterialListPage")
    public CommonResult querySendOutMaterialListPage(@RequestBody SendOutMaterialListPage sendOutMaterialListPage) {
        return CommonResult.success(sendOutMaterialListService.querySendOutMaterialListPage(sendOutMaterialListPage));
    }
/*
    @ApiOperation("修改&&删除委外发料单")
    @PostMapping("/updateSendOutMaterialList")
    public CommonResult updateSendOutMaterialList(@RequestBody SendOutMaterialList sendOutMaterialList){
        return CommonResult.success(sendOutMaterialListService.updateById(sendOutMaterialList));
    }*/

    @ApiOperation("通过id查询委外发料单详情")
    @GetMapping("/querySendOutMaterialListById")
    public CommonResult querySendOutMaterialListById(long id) {
        return CommonResult.success(sendOutMaterialListService.querySendOutMaterialListById(id));
    }

}
